package agriculture.util;

public class Result<T> {
    private boolean success;
    private String message;
    private T data;
    private int code;

    public Result() {
    }

    // 自动设置 success，根据 code 判断成功（例如 code==200 表示成功）
    public Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.success = (code == 200);
    }

    // 可选：其他构造方法
    public boolean isSuccess() {
        return success;
    }
    public void setSuccess(boolean success) {
        this.success = success;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public T getData() {
        return data;
    }
    public void setData(T data) {
        this.data = data;
    }
    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
        this.success = (code == 200);
    }
}
